package dhadi.use.swing;

import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

public class BoardUiMouseMotionListener implements MouseMotionListener
{
	private BoardUi boardUi;
	public BoardUiMouseMotionListener(BoardUi boardUi)
	{
		this.boardUi = boardUi;
	}
	
	public void mouseDragged(MouseEvent e) {
		if (this.boardUi.getMovingPick() != null)
		{	
			this.boardUi.getMovingPick().onMouseDragged(e);
			this.boardUi.repaint();
		}
	}
	
	public void mouseMoved(MouseEvent e) {
		int x = e.getX();
		int y = e.getY();
		PickUi pick = this.boardUi.layout.getMatchingPic(x, y);
		this.boardUi.setMovingPick(pick);
		this.boardUi.repaint();
	}
}
